home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Lattice C v5.02 d4.adf / examples / debugger / dbptr.cpr < prev    next >
Text File  |  1988-11-07  |  1KB  |  41 lines

  1. /* 
  2. DBPTR -- Dump memory as bytes for a given BPTR
  3.          (1 byte hex values with text)
  4.   DBPTR (<variable> | <address> | <range>)
  5.    >dbptr var         /* Dumps 64 bytes pointed to by BPTR var   */
  6.    >dbptr var l 10    /* Dumps 10 bytes pointed to by BPTR var   */
  7.    >dbptr 0x82034     /* Dumps 64 bytes from location 0x002080d0 */
  8.    >dbptr 0x82034 l 5 /* Dumps 5 bytes from location 0x002080d0  */
  9. Note that a BPTR is an address shifted right 2.
  10. */
  11. parse arg expr ' l ' len ' L ' len2
  12. if (expr = '?') then
  13.    do
  14.    do i = 2 to 9
  15.       'd "' strip(sourceline(i),'T', "0a"x) '"'
  16.    end
  17.    exit(0)
  18.    end
  19. options failat 3
  20. options results
  21. 'd ' expr
  22. stat = rc
  23. val = strip(result,'T',"0a"x)
  24. options
  25. if (stat ~= 0) then
  26.    do
  27.    'd "Error: can''t find' expr '"'
  28.    exit(0)
  29.    end
  30. val = strip(val)
  31. if (~datatype(val,'x')) then
  32.    do
  33.    'd "       ^------------should be an ''address''"'
  34.    exit(0)
  35.    end
  36. lenspec = ''
  37. if (len  ~= '') then lenspec = 'l' len
  38. if (len2 ~= '') then lenspec = 'L' len2
  39. 'db 0x'|| c2x(d2c(c2d(x2c(val))*4,4)) lenspec
  40. exit(0)
  41.